package com.hx.springboot1.controller;

import com.github.pagehelper.PageInfo;
import com.hx.springboot1.pojo.entity.TabCourse;
import com.hx.springboot1.pojo.entity.TabStudent;
import com.hx.springboot1.service.StuService;
import com.hx.springboot1.service.impl.CourseServiceImpl;
import com.hx.springboot1.utils.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Author: hx
 * Date: 2021-05-24 14/45
 * Description: Nothing else
 */
@Controller
public class CourseController {
    @Autowired
    CourseServiceImpl courseService;
    @RequestMapping("/selectCourse")
    public String selectCourse(String searchName, String pageNum, String pageSize, Model model){
        PageInfo pageInfo = courseService.selectAllCourse(searchName, pageNum, pageSize);
        model.addAttribute("pageInfo",pageInfo);
        return "manage/courseList";
    }
    @PostMapping("/insertOrUpdateCourse")
    @ResponseBody
    public ResultMsg iouCourse(Integer courseId,String courseName,Integer score,Integer term,String courseType,String testType,Integer courseHour,Integer practiceHour){
        return courseService.insertOrUpdateCourse(courseId,courseName,score,term,courseType,testType,courseHour,practiceHour);
    }
    @GetMapping("/selectCourseById")
    @ResponseBody
    public TabCourse sCbI(Integer courseId){
        return courseService.selectCourseById(courseId);
    }
    @GetMapping("/deleteCourseInfo")
    @ResponseBody
    public ResultMsg deleteCourse(Integer CID){
        return courseService.delCourse(CID);
    }
    @GetMapping("/selectCourseByYearId")
    @ResponseBody
    public List<TabCourse> selectCourseByYearId(Integer yearId){
        return courseService.selectCourseByYearId(yearId);
    }
}
